#include <bits/stdc++.h>
using namespace std;

int count(int n, int x) {
	int sum = 0;
	while (n > 0) {
		int temp = n % 10;
		if (temp == x) {
			sum++;
		}
		n /= 10;
	}
	return sum;
}

int main() {
	int n, x;
	int sum = 0;
	cin >> n >> x;
	for (int i = 1; i <= n; ++i) {
		sum += count(i, x);
	}
	cout << sum;
	return 0;
}